#ifndef AT_NETWORK_SOCKET_EC200_h
#define AT_NETWORK_SOCKET_EC200_h

#include "extend/socket/AtNetworkSocket.h"
#include "extend/socket/AtNetworkSocketUrcRecv.h"
#include "extend/socket/AtNetworkSocketUrcState.h"

class AtNetworkSocketEC200 : public AtNetworkSocket {
  protected:
    AtNetworkUrc *urcState;
    AtNetworkUrc *urcRecv;

  public:
    AtNetworkSocketEC200(AtNetworkDevice *device, GSM_STRING stype, uint8_t cid = 0)
        : AtNetworkSocket(device, stype, cid) {
      this->urcState = new AtNetworkSocketUrcState(this, AT_SOCKET_CMD);
      this->urcRecv = new AtNetworkSocketUrcRecv(this, AT_SOCKET_CMD);

      sprintf(this->urcState->urcCmd, "+QIURC: \"closed\",%d", cid);
      sprintf(this->urcRecv->urcCmd, "+QIURC: \"recv\",%d,", cid);
    };

    ~AtNetworkSocketEC200() {
      delete this->urcState;
      delete this->urcRecv;
    };

    /**
     * URC回调接口函数(状态变化)
     */
    virtual void urcWithClose(void *param);

    /**
     * URC回调接口函数(收到数据)
     */
    virtual void urcWithRecv(void *param);

  protected:
    /**
     * 写入一段数据
     * @param buf 数据
     * @param size 长度
     */
    virtual size_t write0(const uint8_t *buf, size_t size);

    /**
     * 连接到指定IP:PORT
     * @param host IP地址
     * @param port 端口
     */
    virtual int connect0(const char *host, uint16_t port);

    /**
     * 断开连接
     */
    virtual void disconnect0(uint8_t cid = 0);
};

#endif